package pers.cocoadel.cloud.movie.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import pers.cocoadel.cloud.movie.domain.User;

import java.math.BigDecimal;

@Service
@FeignClient(name = "user-service", fallback = UserFeignClient.UserFeignClientFallback.class)
public interface UserFeignClient
{
    @GetMapping("/users/{id}")
    User findById(@PathVariable("id") Long id);

    @Component
    class UserFeignClientFallback implements UserFeignClient
    {
        @Override
        public User findById(Long id)
        {
            return new User(id, "cocoadel", "cocoadel", 0, new BigDecimal(1));
        }
    }
}
